package com.bookhouse.service.impl;

import java.util.List;

import com.bookhouse.dao.ReaderDao;
import com.bookhouse.domain.Reader;
import com.bookhouse.service.ReaderService;

public class ReaderServiceImpl implements ReaderService {

	ReaderDao readerDao;

	public void setReaderDao(ReaderDao readerDao) {
		this.readerDao = readerDao;
	}

	@Override
	public void saveReader(Reader reader) {
		if (reader.getId() != null && reader.getId() > 0)
			readerDao.update(reader);
		else
			readerDao.save(reader);
	}

	@Override
	public List<Reader> getAllReader() {
		return readerDao.findAll(Reader.class);
	}

	@Override
	public Reader getReader(int id) {
		return readerDao.get(Reader.class, id);
	}

	@Override
	public void deleteReader(int id) {
		readerDao.delete(Reader.class, id);
	}

}
